import { useStore } from '@renderer/store/useStore'
import { useEffect } from 'react'
import { Alert } from 'antd'

export default function Error() {
  const error = useStore((state) => state.error)
  const setError = useStore((state) => state.setError)
  useEffect(() => {
    const timer = setTimeout(() => {
      setError('')
    }, 1000)
    return () => {
      clearTimeout(timer)
    }
  }, [error])
  return (
    <>
      {error ? (
        <div className={'absolute top-0 w-full h-full'}>
          <Alert message={error} type="error" />
        </div>
      ) : null}
    </>
  )
}
